<?php
global $MONTHS2, $TYPE_MAVRO, $VALUTA,$USER_SETTING;
?>
<h1>Переоформление мавро. Шаг 2</h1>

<script type="text/javascript" src='<?=config_item('js_path')?>js/modify.js?<?=time()?>'></script>
<script type="text/javascript" src='<?=config_item('js_path')?>js/mavro.js?<?=time()?>'></script>
<script language="javascript" src='<?=config_item('js_path')?>js/buy.js?<?=time()?>'></script>
<script type="text/javascript">
var opers = <?=json_encode($opers)?>;
var kurses = <?=json_encode($kurses)?>;
var users_l = <?=json_encode($users_l)?>;
var users_des = <?=json_encode($users_des);?>;

$(document).ready(function(){
	changeCountMavro(<?=$selected_oper_id?>); 
	changeUserIsDes();
	countSumm();
});

</script>

<form method=post action='modify/save' enctype='multipart/form-data' id='f'>
	<input type='hidden' name='user_id' value='<?=$user['id']?>'>
	<table class='edit' cellspacing=0>
		<tr>
			<td>Участник</td>
			<td width=100%><?=$user['fio']?> <a href='modify/'>Сменить</a></td>
		</tr>
		<tr>
			<td colspan=2><b>Продажа</b></td>
		</tr>
		<tr>
			<td valign=top>Вклад</td>
			<td>
				<div style="max-height:250px; overflow:auto;">
					<table class='list operations' cellspacing=0 style="width:auto;">
					<?php foreach($opers as $opers => $oper) { ?>
						<tr>
							<td><input type='radio' name='oper_id' value='<?=$oper['id']?>' id='oper_<?=$oper['id']?>' onchange="changeCountMavro(<?=$oper['id']?>); countSumm();" <?php if($selected_oper_id == $oper['id']) echo "checked"; ?>></td>
							<td class='<?=($oper['bonus']) ? 'bonus' : ''?> o_date'><?=$oper['day']?>.<?=$oper['month']?>.<?=$oper['year']?></td>
							<td class='<?=($oper['bonus']) ? 'bonus' : ''?> <?=$oper['type']?> o_summ'><?=$oper['summ']?> <?=$VALUTA[$oper['valuta']]?></td>
							<td class='<?=($oper['bonus']) ? 'bonus' : ''?> <?=$oper['type']?> o_kurs'>
								<?php if($oper['kurs_valuta'] > 0 && $oper['kurs_valuta'] != 1) echo round($oper['kurs_valuta'], 4)." / "; ?>
								<?=$oper['kurs']?> <?=$VALUTA[$oper['mavro_valuta']]?> (<?=$oper['percent']?>%)</td>
							<td class='<?=($oper['bonus']) ? 'bonus' : ''?> <?=$oper['type']?> o_mavro'><?=$oper['mavro']?> <?=$oper['mavro_valuta']?> </td>
							<td class='<?=($oper['bonus']) ? 'bonus' : ''?> o_hranen'><?=$oper['hranen']?></td>
							<td class='<?=($oper['bonus']) ? 'bonus' : ''?> o_dop'><?=$oper['dop']?></td>
						</tr>
					<?php } ?>
					</table>
				</div>
			</td>
		</tr>
		<tr>
			<td>Дата</td>
			<td>
			<select name='day' onchange="changeUserIsDes(); countSumm(); countMavro();">
				<?php for($i = 1; $i<=31; $i++) {?>
					<option value='<?=$i?>' <?php if($i == date('j')) echo "selected"; ?>><?=$i?></option>
				<?php } ?>
			</select> . <select name='month' onchange="changeUserIsDes(); countSumm(); countMavro();">
				<?php foreach($MONTHS2 as $k => $v) {?>
					<option value='<?=$k?>' <?php if($k == date('m')) echo "selected"; ?>><?=$v?></option>
				<?php } ?>
			</select> . <select name='year' onchange="changeUserIsDes(); countSumm(); countMavro();">
				<?php for($i = 2011; $i<=(date("Y") + 1); $i++) {?>
					<option value='<?=$i?>' <?php if($i == date('Y')) echo "selected"; ?>><?=$i?></option>
				<?php } ?>
			</select>
			</td>
		</tr>
		<tr>
			<td>Количество мавро</td>
			<td><input type='text' name='mavro_summ' value='' onchange="checkMavroSumm(); countSumm(); countMavro();" onkeyup="countSumm(); countMavro();" style="width:120px;"><input type='text' readonly name='percent' value='' style="border:0px; width:120px;"></td>
		</tr>
		<tr>
			<td>Курс продажи</td>
			<td>
				<input type='text' readonly name='kurssale' value='' style="border:0px; border;0px; width:100px;">
				<label id='l_use_kurs_sale_buy'><input type="checkbox" name="use_kurs_sale_buy" value='buy' onchange="countSumm(); countMavro();"> Использовать курс покупки</label>
			</td>
		</tr>
		<tr>
			<td>Получившаяся сумма</td>
			<td>
				<input type='text' readonly name='summ' value='' style="border:0px; border;0px; width:170px;">
				<select name='valuta' style="display:none;">
				<?php foreach($VALUTA as $k => $v) {?>
					<option value='<?=$k?>'><?=$v?></option>
				<?php } ?>
			</select>
			</td>
		</tr>



		<tr>
			<td colspan=2><b>Покупка</b></td>
		</tr>
		<tr>
			<td>Сумма:</td>
			<td>
				<input type='text' readonly name='summ_buy' value='' style="border:0px; border;0px; width:170px;">
			</td>
		</tr>
		<tr>
			<td>Тип мавро:</td>
			<td><select name='mavro_type_buy' onchange="countMavro()">
				<option value=''></option>
				<?php foreach($TYPE_MAVRO as $k => $v) {
					if($k == 'week') continue;
					?>
					<option value='<?=$k?>'><?=$v?></option>
				<?php } ?>
			</select> <input type='checkbox' name='sverh' value='1' onchange="countMavro()"> Сверхдоходные</td>
		</tr>
		<tr>
			<td>Курс покупки:</td>
			<td><input type='text' readonly name='kurs_buy' value='' style="border:0px; width:70px;"></td>
		</tr>
		<tr>
			<td>Курс валюты:</td>
			<td>
				<input type='text' readonly name='kurs_valuta' value='' style="width:100px;" class='noborder' onchange="chKursValuta(this)" onkeyup="chKursValuta(this)"> 
				<span id='kurs_valuta_reverse' style="display:none;"><input type='checkbox' name='kurs_valuta_reverse' value='1' onchange="changeKursValutaReverse(this)"> Обратный курс</span>
				<span id='kurs_valuta_text' style="margin-left:50px;"></span>
			</td>
		</tr>
		<tr>
			<td>Мавро:</td>
			<td>
				<input type='text' readonly name='mavro' value='' style="border:0px; border;0px; width:80px;"> 
				<select name='mavro_valuta' onchange="countMavro()">
					<?php foreach($VALUTA as $k => $v) {?>
						<option value='<?=$k?>' <?php if($USER_SETTING['valuta'] == $k) echo 'selected'; ?>><?=$v?></option>
					<?php } ?>
				</select>
				<input type='text' readonly name='mavro_percent' value='' style="border:0px; border;0px; width:70px;">
				<span id='mavro_text'></span>
			</td>
		</tr>
		<tr>
			<td>Дополнительно</td>
			<td><input type='text' name='dop' value=''></td>
		</tr>
	</table>
	<br>
	<input type='submit' value='Сохранить' name='subm'>

</form>
